﻿using System.Data;

namespace DAL
{
    public class Order_Buy_DAL : clsConnect
    {
        private static readonly clsConnect cls = new clsConnect();
        #region[Get-Data]
        public DataTable GetOrderBuy(string keywords)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@KEYWORDS", keywords);
            return cls.GetData("sp_tb_Order_Buy");
        }
        public DataTable GetOrderBuyEdit(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Order_Buy_Id", id);
            return cls.GetData("sp_tb_Order_Buy_Edit");
        }
        public DataTable GetOrderBuyOrderOfOrder(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Order_Id", id);
            return cls.GetData("sp_tb_Order_Buy_Of_Order");
        }
        public DataTable GetOrderBuyDetail(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Order_Buy_Id", id);
            return cls.GetData("sp_tb_Order_Buy_Detail");
        }
        public static DataTable GetOrderBuyFillterDate(string DateBegin, string DateEnd)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@DateBegin", DateBegin);
            cls.AddParameter("@EndBegin", DateEnd);
            return cls.GetData("sp_tb_Order_Buy_FillterDate");
        }
        #endregion

        #region[Insert-Update-Delete]
        //public bool InsertOrderBy(Order_Buy_ET data)
        //{
        //    SqlCommand cmd = new SqlCommand();
        //    cmd.Connection = GetConnection();
        //    cmd.CommandType = CommandType.StoredProcedure;
        //    cmd.CommandText = "tb_Order_Buy_Insert";

        //    cmd.Parameters.Add("@Order_Id", SqlDbType.Int).Value = data.Order_Id;
        //    cmd.Parameters.Add("@Order_Buy_Code", SqlDbType.NVarChar).Value = data.Order_Buy_Code;
        //    cmd.Parameters.Add("@Order_Buy_DateBegin", SqlDbType.DateTime).Value = data.Order_Buy_DateBegin;
        //    cmd.Parameters.Add("@Order_Buy_DateEnd", SqlDbType.DateTime).Value = data.Order_Buy_DateEnd;
        //    cmd.Parameters.Add("@Order_Buy_Tax_Code", SqlDbType.NVarChar).Value = data.Order_Buy_Tax_Code;
        //    cmd.Parameters.Add("@Order_Buy_Description", SqlDbType.NVarChar).Value = data.Order_Buy_Description;
        //    cmd.Parameters.Add("@Order_Buy_Payment_Type", SqlDbType.NVarChar).Value = data.Order_Buy_Payment_Type;
        //    cmd.Parameters.Add("@Order_Buy_Uesr_ID", SqlDbType.Int).Value = data.Order_Buy_Uesr_ID;
        //    cmd.Parameters.Add("@Customer_ID", SqlDbType.Int).Value = data.Customer_ID;
        //    cmd.Parameters.Add("@Users_Id", SqlDbType.Int).Value = data.Users_Id;
        //    cmd.Parameters.Add("@Order_Buy_Id", SqlDbType.Int).Direction = ParameterDirection.Output;
        //    cmd.ExecuteNonQuery();
        //    data.Order_Buy_Id = int.Parse(cmd.Parameters["@Order_Buy_Id"].Value.ToString());
        //    return true;
        //}
        //public bool UpdateOrderBuy(Order_Buy_ET data)
        //{
        //    cls.CreateNewSqlCommand();
        //    cls.AddParameter("@Order_Buy_Id", data.Order_Buy_Id);
        //    cls.AddParameter("@Order_Buy_Code", data.Order_Buy_Code);
        //    cls.AddParameter("@Order_Buy_DateBegin", data.Order_Buy_DateBegin);
        //    cls.AddParameter("@Order_Buy_DateEnd", data.Order_Buy_DateEnd);
        //    cls.AddParameter("@Order_Buy_Tax_Code", data.Order_Buy_Tax_Code);
        //    cls.AddParameter("@Order_Buy_Description", data.Order_Buy_Description);
        //    cls.AddParameter("@Order_Buy_Uesr_ID", data.Order_Buy_Uesr_ID);
        //    return cls.ExecuteNonQuery("sp_tb_Order_Buy_Detail_Update");
        //    return true;
        //}
        //public bool DeleteOrderDetailTempAll(int id)
        //{
        //    cls.ExecuteNonQuery("sp_tb_Order_Buy_Detail_Temp_Delete_All", "@Users_Id", id);
        //    return true;
        //}
        //public bool DeleteOrderBuy(int id)
        //{
        //    cls.ExecuteNonQuery("sp_tb_Order_Buy_Delete", "@Order_Buy_Id", id);
        //    return true;
        //}
        #endregion

        #region[Search-Fillter]
        public DataTable SearchOrder(string keywords)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@KEYWORDS", keywords);
            return cls.GetData("sp_tb_Order_Buy");
        }
        #endregion
    }
}